<template>
	<view>
		<button style="height: 100rpx;" @click="setClientId">设置厂商标识ID</button>
		<button style="height: 100rpx;" @click="setServerUrl">设置sdk服务地址</button>
		
		<button style="height: 100rpx;" @click="getServerEnvType">获取sdk的服务地址类型</button>
		
		<button style="height: 100rpx;" @click="downCert">下载证书</button>
		<button style="height: 100rpx;" @click="updateCert">更新证书</button>
		<button style="height: 100rpx;" @click="resetpin">证书密码重置</button>
		<button style="height: 100rpx;" @click="showCert">查看证书</button>
		<button style="height: 100rpx;" @click="clearCert">清除本地证书</button>
		<button style="height: 100rpx;" @click="existsCert">本地是否下载了证书</button>
		<button style="height: 100rpx;" @click="getUserInfo">获取证书用户信息</button>
		<button style="height: 100rpx;" @click="getOpenId">获取证书用户openId</button>
		<button style="height: 100rpx;" @click="getStampPic">获取证书用户个人签章图片</button>
		<button style="height: 100rpx;" @click="drawStamp">设置个人签章</button>
		<button style="height: 100rpx;" @click="sign">签名</button>
		<button style="height: 100rpx;" @click="keepPin">开启免密签名</button>
		<button style="height: 100rpx;" @click="isPinExempt">是否处于免密签名状态</button>
		<button style="height: 100rpx;" @click="clearPin">清除免密签名</button>
		<button style="height: 100rpx;" @click="signForSignAuto">请求开启自动签名</button>
		<button style="height: 100rpx;" @click="signAutoInfo">获取自动签名状态</button>
		<button style="height: 100rpx;" @click="stopSignAuto">停止自动签名</button>
		<button style="height: 100rpx;" @click="getVersion">获取当前版本号</button>
	</view>
</template>

<script>
	//const sign = uni.requireNativePlugin('ux-sign');
	export default {
		data() {
			return {

			}
		},
		methods: {
			setClientId() {
				let that = this;
				let clientId = "2019040114391224"; //厂商标识id
			    that.$lobster.sign.setClientId(clientId, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			setServerUrl() {
				let that = this;
				that.$lobster.sign.setServerUrl(1,res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			getServerEnvType() {
				let that = this;
				that.$lobster.sign.getServerEnvType(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			downCert() {
				let that = this;
				let phone = "15874078354";
				that.$lobster.sign.downCert(phone, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			updateCert() {
				let that = this;
				that.$lobster.sign.updateCert(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			resetpin() {
				let that = this;
				that.$lobster.sign.resetpin(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			showCert() {
				let that = this;
				that.$lobster.sign.showCert(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			clearCert() {
				let that = this;
				that.$lobster.sign.clearCert(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			existsCert() {
				let that = this;
				that.$lobster.sign.existsCert(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			getUserInfo() {
				let that = this;
				that.$lobster.sign.getUserInfo(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			getOpenId() {
				let that = this;
				that.$lobster.sign.getOpenId(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			getStampPic() {
				let that = this;
				that.$lobster.sign.getStampPic(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			drawStamp() {
				let that = this;
				that.$lobster.sign.drawStamp(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			sign() {
				let that = this;
				var data = []; //待签数据同步到医网信返回的uniqueId的列表
				data.push("3925a23c6aa34f65bb27cc30439253aa");
				data.push("0725d95da332493f9ce8823d03ff9dd4");
				data.push("888888");
				that.$lobster.sign.signData(data, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			keepPin() {
				let that = this;
				let keepDay = 30; //免密时间（1-60天）
				that.$lobster.sign.keepPin(keepDay, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			isPinExempt() {
				let that = this;
				that.$lobster.sign.isPinExempt(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			clearPin() {
				let that = this;
				that.$lobster.sign.clearPin(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			signForSignAuto() {
				let that = this;
				let sysTag = "NULL"; //待签名数据的系统标识名
				that.$lobster.sign.signForSignAuto(sysTag, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			signAutoInfo() {
				let that = this;
				that.$lobster.sign.signAutoInfo(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			stopSignAuto() {
				let that = this;
				let sysTag = ""; //自动签名的系统标识名，为空时候表示停止所有业务系统
				that.$lobster.sign.stopSignAuto(sysTag, res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
			getVersion() {
				let that = this;
				that.$lobster.sign.getVersion(res => {
					console.log(JSON.stringify(res));
					this.$util.showToast(JSON.stringify(res))
				})
			},
		}
	}
</script>

<style>

</style>
